#!/usr/bin/env python

# --------------------------------------
# projects/python/primes/TestCollatz.py
# Copyright (C) 2009
# Glenn P. Downing
# --------------------------------------

# To run the tests
#     python TestPrimes.py

# To document the tests
#     pydoc -w TestPrimes

import main
import unittest

# ----------
# TestReader
# ----------

class TestReader (object) :
    def __init__ (self, s) :
        self.s = s

    def read (self) :
        return self.s

# ----------
# TestWriter
# ----------

class TestWriter (object) :
    def str (self) :
        return self.s

    def write (self, *a) :
        self.s = str(a[0])
        for w in a[1:] :
            self.s += ' '
            self.s += str(w)
        self.s += '\n'

# -----------
# TestCollatz
# -----------

class TestPrimes (unittest.TestCase) :

	# ----
	# eval
	# ----

	def test_eval1 (self) :
		main.i =  35
		main.my_eval()
		self.assert_(main.v + main.x + main.y + main.z == main.i)

	def test_eval2 (self) :
		main.i =  24
		main.my_eval()
		self.assert_(main.v + main.x + main.y + main.z == main.i)

	def test_eval3 (self) :
		main.i =  36
		main.my_eval()
		self.assert_(main.v + main.x + main.y + main.z == main.i)

	def test_eval4 (self) :
		main.i =  46
		main.my_eval()
		self.assert_(main.v + main.x + main.y + main.z == main.i)

	def test_eval5 (self) :
		main.i =  2451
		main.my_eval()
		self.assert_(main.v + main.x + main.y + main.z == main.i)

	def test_eval6 (self) :
		main.i =  98787
		main.my_eval()
		self.assert_(main.v + main.x + main.y + main.z == main.i)

	def test_eval7 (self) :
		main.i =  3515
		main.my_eval()
		self.assert_(main.v + main.x + main.y + main.z == main.i)

	def test_eval8 (self) :
		main.i =  8
		main.my_eval()
		self.assert_(main.v + main.x + main.y + main.z == main.i)

	def test_eval11 (self) :
		for k in range(8, 10000, 1) :
			main.i =  k
			main.my_eval()
			self.assert_(main.v + main.x + main.y + main.z == main.i)
			self.assert_(main.testPrime(main.v))
			self.assert_(main.testPrime(main.x))
			self.assert_(main.testPrime(main.y))
			self.assert_(main.testPrime(main.z))


if __name__ == "__main__" :
    unittest.main()

